#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    struct Info
    {
        int num;
        int times;
    };
    Info a[1001];
    int aLen= 0;
    
    for(int i = 0; i<N; i++)
    {
        int temp;
        cin >> temp;
        bool ifSaw = false;
        for(int j = 0; j<aLen; j++)
        {
            if(a[j].num == temp)
            {
                a[j].times++;
                ifSaw = true;
                break;
            }
            
        }
        if(ifSaw == false)
        {
            a[aLen].num = temp;
            a[aLen].times = 1;
            aLen++;
        }
        
    }

    int maxTimes = a[0].times;
    int maxNum = a[0].num;
    for(int i = 0; i<aLen; i++)
    {
        if(a[i].times > maxTimes)
        {
            maxTimes = a[i].times;
            maxNum= a[i].num;
        }
    }
    cout << maxNum << " "<< maxTimes;
}